package cn.pku.ss.sirx.sna.ib;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import cn.pku.ss.sirx.sna.ib.bean.MessageBoard;
import cn.pku.ss.sirx.sna.ib.db.InfluenceDao;

/**
 * Iterator of all message boards.
 *
 * @author SirX
 * @version 1.0
 */
public class MessageBoardIterator implements Iterator<MessageBoard> {

    /**
     * Constructor.
     */
    public MessageBoardIterator() {
        List<MessageBoard> messageBoardList = new LinkedList<MessageBoard>();
        for( String ownerId : InfluenceDao.getInstance().getMeesageBoardOwnerIds()) {
            MessageBoard messageBoard = new MessageBoard();
            messageBoard.setOwnerId(ownerId);
            messageBoardList.add(messageBoard);
        }
        this.messageBoardIterator = messageBoardList.iterator();
    }

    @Override
    public boolean hasNext() {
        return this.messageBoardIterator.hasNext();
    }

    @Override
    public MessageBoard next() {
        return this.messageBoardIterator.next();
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
    
    private Iterator<MessageBoard> messageBoardIterator;

}
